# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 1:08
# @Author  : yangqing
# @Email   : 1292504517@qq.com
# @File    : Consignee_Information_page.py
# @Software: PyCharm
from time import sleep
from selenium.webdriver.support.select import Select
from page.base_page import BasePage
from selenium.webdriver.common.by import By
'''收货人信息page'''
class ConsigneeInformation(BasePage):
        # def __init__(self, driver):
        #         self.driver = driver

        ele_tbody_locator = (By.XPATH, '//*[@id="theForm"]/div/table/tbody')
        # 找到国家下拉框
        ele_select_country_locator = (By.XPATH, '//*[@id="selCountries_0"]')
        # 找到省下拉框
        ele_select_province_locator = (By.XPATH, '//*[@id="selProvinces_0"]')
        # 找到市下拉框
        ele_select_city_locator = (By.ID, 'selCities_0')
        # 找到区
        ele_select_area_locator = (By.XPATH, '//*[@id="selDistricts_0"]')
        #  找到收货人姓名
        ele_ContacterName_locator = (By.NAME, 'consignee')
        # 找到详细地址
        ele_address_locator = (By.NAME, 'address')
        # 找到电话
        ele_phone_locator = (By.NAME, 'tel')
        # 找到电子邮件地址
        ele_email_locator = (By.NAME, 'email')
        # 找到配送至这个地址
        ele_delivery_btn_locator = (By.NAME, 'Submit')



        # 定位国家下拉框
        def select_country(self):
                select_country = self.driver.find_element(*self.ele_select_country_locator)
                select1 = Select(select_country)
                select1.select_by_index(1)


        # 定位省下拉框
        def select_province(self):
                select_province = self.driver.find_element(*self.ele_select_province_locator)
                select = Select(select_province)
                select.select_by_index(25)

        # 定位市下拉框
        def select_city(self):
                select_city = self.driver.find_element(*self.ele_select_city_locator)
                select = Select(select_city)
                select.select_by_visible_text("成都")

        # 定位区
        def select_area(self):
                select_area = self.driver.find_element(*self.ele_select_area_locator)
                select = Select(select_area)
                select.select_by_visible_text("锦江区")

        # 收货人姓名输入
        def ContacterName(self):
                self.driver.find_element(*self.ele_ContacterName_locator).send_keys('张三')

        # 详细地址、电话、电子邮件
        def address(self):
                self.driver.find_element(*self.ele_address_locator).send_keys('成都市锦江区东方广场')
        def phone(self):
                self.driver.find_element(*self.ele_phone_locator).send_keys('18223332232')
        def email(self):
                self.driver.find_element(*self.ele_email_locator).send_keys('129373@qq.com')

        # 配送至这个地址按钮
        def delivery_btn(self):
                self.driver.find_element(*self.ele_delivery_btn_locator).click()
